package chapter1.fundamentals.example;

import edu.princeton.cs.algs4.StdIn;
import edu.princeton.cs.algs4.StdOut;

/**
 * @author quanlinlin on 2018/10/24 20:48.
 * @version 1.0
 */
public class Average {

    public static void main(String[] args) {

        double sum = 0;
        int cnt = 0;
        while (!StdIn.isEmpty()) {
            sum += StdIn.readDouble();
            cnt++;
        }
        double avg = sum / cnt;
        StdOut.printf("Average is %.5f\n", avg);
    }
}
